/**
 *
 *@author ZhouLan
 *@version 1.0.0
 */

export class GoodsDetail{
  //商品id号
  //商品图片url数组
  goodsId:string //商品id号，必填
  businessId:string //所属商家的id号，必填
  imageUrl:string //商品的标题图片，必填
  //imageUrl在数据库中是一个用字符拼接的长字符串，设想用一个单独的接口来取这个长字符串分割并包装成数组，或者在一个接口中完成整个对象的包装实际也是可行的
  title:string//商品标题，必填
  price:number//商品单价，必填
  duration:number //存储天数，会转换成年月日来显示，必填
  specification:string//规格，必填
  // detailImages:Array<string>//详细图片，必填
  logoUrl:string //商家logo的路径，必填
  shopName:string//商品名，必填
  goodsGroup:number  //商品小类，必填
  goodsClass:number  //商品大类，必填
  discount:boolean = false//默认没有折扣
  discount_price?:number//折扣价
  // labels?:Array<string>//标签
  storage?:number = 0//储存方式，0代表低温，1代表常温
  //删除详细图片数组和标签数组，这两个的获取由其他请求实现
  timestamp:number//时间戳，上传的事件
  getExampleString(){
    let json = {
      "goodsId":"123",
      "businessId":"111",
      "imageUrl":"11",
      "title":"1111",
      "price":12.34,
      "duration":3,
      "specification":"一斤",
      "logoUrl":"http:localhost:8081/imgs",
      "shopName":"测试",
      "goodsGroup":1,
      "goodsClass":2,
      "discount":0,
      "discount_price":0,
      "storage":0,
      "timestamp":new Date().getTime()
    }
    return JSON.stringify(json)
  }

  // labels?:Array<string>//labels不需要放在此位置
  // detailImages?:Array<string>

  constructor(goodsId:string,businessId:string,imageUrl:string,title:string,price:number,duration:number,specification:string,logoUrl:string,shopName:string,goodsGroup:number,goodsClass:number,discount?:boolean,discount_price?:number,storage?:number) {
    this.goodsId = goodsId
    this.imageUrl = imageUrl
    this.title = title
    this.price = price
    if(discount!=undefined){
      this.discount = discount
    }
    if(discount_price!=undefined){
      this.discount_price = discount_price
    }
    this.storage = storage
    this.duration = duration
    this.specification = specification
    // this.detailImages = detailImages
    this.businessId = businessId
    this.logoUrl = logoUrl
    this.shopName = shopName
    this.goodsGroup = goodsGroup
    this.goodsClass = goodsClass
    this.timestamp = Math.round(new Date().getTime()/1000)//秒级时间戳
  }
  toString():string{
    return JSON.stringify(this)
  }
}
/*
 * 使用这个类的组件:
 * pages/component/waterFlowTest ——获取并将此类的对象传递给waterFlowCard
 * pages/component/waterFlowCard ——展示商品卡片信息
 * pages/GoodsDetailPage ——显示商品的详细信息
 * pages/component/classifyGoodsContent ——展示卡片商品信息*/

//商品信息页的商品信息展示类
//商品信息页面中的评论对象，包含评论用户的昵称，头像，评论内容，分数等等
export class GoodsComment{
  user_id:string
  userNickName:string
  userIconUrl:string
  score:number//用户评分
  text:string//用户的具体评论
  constructor(nickName:string,iconUrl:string,score:number,text:string,user_id:string) {
    this.userNickName = nickName
    this.userIconUrl = iconUrl
    this.score = score
    this.text = text
    this.user_id = user_id
  }
}

//考虑将非详细的商品信息提供批量卡片展示时使用
export class GoodsCard{
  goodsId:string
  imageUrl:string
  title:string
  price:string
  logoUrl:string
  shopName:string
  goodsGroup:number  //商品大类
  goodsClass:number  //商品小类
  // constructor() {
  // }
}
//各种商品card的显示类
//只不过在这个案例中，无法通过这个类查询到详细信息